/**
 * @(#) MenuController.java
 */

package TheRestaurantOwner;

public class MenuController
{
	private Restaurant restaurant;
	
	public MenuController( Restaurant restaurant )
	{
		this.restaurant = restaurant;
	}
	
	public void chooseMenuItems( )
	{
		System.out.println("Choose your menu items!");
		
		// Offer random names/qualities
		String[] randomDishNames = new String[] { "Noodles", "Burger", "Fish Filet", "Duck a la carte", "Potato Salad" };
		String[] randomQualities1 = new String[] { "low", "low", "high", "high", "high" };
		String[] randomBeverageNames = new String[] { "Water", "Bubbly water", "Orange Juice", "Beer", "Vodka" };
		String[] randomQualities2 = new String[] { "high", "low", "high", "high", "low" };
		
		java.util.Random random = new java.util.Random();
		Player player = restaurant.getOwner();
		Menu menu = restaurant.getMenu();
		for (int i = 0; i < 5; i++){
			String name = player.input("Dish name: ", randomDishNames[i]);
			String qualityStr = player.input("Dish quality (low/high): ", randomQualities1[i]);
			ItemQuality quality = ItemQuality.valueOf(qualityStr);
			int calories = random.nextInt(1000) + 200;
			Dish dish = new Dish(name, quality, calories);
			menu.setDish(i, dish);
		}
		
		for (int i = 0; i < 5; i++){
			String name = player.input("Beverage name: ", randomBeverageNames[i]);
			String qualityStr = player.input("Beverage quality (low/high): ", randomQualities2[i]);
			ItemQuality quality = ItemQuality.valueOf(qualityStr);
			int volume = random.nextInt(5) + 10;
			Beverage beverage = new Beverage(name, quality, volume);
			menu.setBeverage(i, beverage);
		}
	}
	
	public void decideCostOfMenuItems( )
	{
		Player player = restaurant.getOwner();
		Menu menu = restaurant.getMenu();
		
		int costOfLowQualityDish = Integer.parseInt(player.input("Cost of low quality dish: ", "10"));
		int costOfHighQualityDish = Integer.parseInt(player.input("Cost of high quality dish: ", "15"));
		int costOfLowQualityBeverage = Integer.parseInt(player.input("Cost of low quality beverage: ", "6"));
		int costOfHighQualityBeverage = Integer.parseInt(player.input("Cost of high quality beverage: ", "9"));
		
		menu.setCosts(costOfLowQualityDish, costOfHighQualityDish, costOfLowQualityBeverage, costOfHighQualityBeverage);
	}
	
	public Menu createMenu( )
	{
		Menu menu = new Menu();
		restaurant.setMenu(menu);
		chooseMenuItems();
		decideCostOfMenuItems();
		return menu;
	}
}
